package cn.yuxirey.verifyedittext.app;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import cn.yuxirey.verifyedittext.OnCompleteListener;
import cn.yuxirey.verifyedittext.VerifyEditText;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        VerifyEditText verifyEditText = findViewById(R.id.verifyedittext);
        verifyEditText.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("click");
            }
        });

        verifyEditText.setOnCompleteListener(new OnCompleteListener() {
            @Override
            public void onComplete(String code) {
                showToast("code: " + code);
            }
        });

        verifyEditText.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                showToast("long clicked");
                return false;
            }
        });

        Button btnOpenDialog = findViewById(R.id.btn_dialog);
        btnOpenDialog.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new CodeDialog(MainActivity.this)
                        .show();
            }
        });
    }

    private void showToast(String text) {
        Toast.makeText(this, text, Toast.LENGTH_SHORT).show();
    }
}